package com.roncoo.education.course.service.api.auth;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.roncoo.education.course.common.bo.auth.AuthCourseTopicViewBO;
import com.roncoo.education.course.common.bo.auth.AuthCourseViewBO;
import com.roncoo.education.course.common.dto.auth.AuthCourseChapterAuditViewDTO;
import com.roncoo.education.course.common.dto.auth.AuthCourseTopicViewDTO;
import com.roncoo.education.course.common.dto.auth.AuthCourseViewDTO;
import com.roncoo.education.course.service.dao.impl.mapper.entity.CourseTopic;
import com.roncoo.education.course.service.dao.service.CourseTopicService;
import com.roncoo.education.util.base.Result;
import com.roncoo.education.util.tools.BeanUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * 查看答题/问答
 *
 */
@Api(tags = "答题/问答相关接口", description = "提供答题/问答相关的 Rest API")
@RestController
@RequestMapping(value = "/course/auth/courseTopic")
public class AuthApiCourseTopicController {

    @Autowired
    private CourseTopicService courseTopicService;
    /**
     * 查看答题
     */
    @ApiOperation(value = "答题/问答详情接口", notes = "用户登录后获取答题/问答详情信息接口")
    @RequestMapping(value = "/view", method = RequestMethod.POST)
    public Result<AuthCourseTopicViewDTO> view(@RequestBody AuthCourseTopicViewBO authCourseViewBO) {
        CourseTopic courseTopic= courseTopicService.getOne(new QueryWrapper<CourseTopic>().select().eq("courseId",authCourseViewBO.getCourseId()));
        if (courseTopic==null){//未找到答题
            return Result.error(404,"未找到课程题库");
        }
        AuthCourseTopicViewDTO authCourseTopicViewDTO = BeanUtil.copyProperties(courseTopic, AuthCourseTopicViewDTO.class);
        return Result.success(authCourseTopicViewDTO);
    }
}
